﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;

namespace lapinou_game2
{
    class Sound
    {

        ContentManager content;
        string sound_status = "none";

        public void PlaySound(ContentManager Content, string sound_name, float volume)
        {
            if (sound_status != "playing")
            {
                this.content = Content;
                SoundEffect soundeffect;
                soundeffect = Content.Load<SoundEffect>(@"audio/" + sound_name);
                SoundEffectInstance soundEffectInstance = soundeffect.CreateInstance();
                soundEffectInstance.Volume = volume;
                soundEffectInstance.Play();
                this.sound_status = "playing";
            }
        }

        public void stopSound(SoundEffect soundEffect, SoundEffectInstance soundEffectInstance)
        {
            soundEffectInstance.Stop();
            soundEffect.Dispose();
            this.sound_status = "none";
        }

        public void setVolume(SoundEffectInstance soundEffectInstance, float volume)
        {
            soundEffectInstance.Volume = volume;
        }
    }
}